//
//  LCShowPlayBarManager.m
//  LCMusicPlayer
//
//  Created by jiukuyinyue on 2017/9/29.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCShowPlayBarManager.h"
#import "LCShowLCPlayBarVCListModel.h"
#import "LSZPraisePoetryAndSermonsVC.h"

@implementation LCShowPlayBarManager

IMPLEMENTATION_SINGLETON(LCShowPlayBarManager)

- (UIViewController *)_topViewController:(UIViewController *)vc {
    if ([vc isKindOfClass:[UINavigationController class]]) {
        return [self _topViewController:[(UINavigationController *)vc topViewController]];
    } else if ([vc isKindOfClass:[UITabBarController class]]) {
        return [self _topViewController:[(UITabBarController *)vc selectedViewController]];
    } else {
        return vc;
    }
    return nil;
}
- (UIViewController *)topViewController {
    UIViewController *resultVC;
    resultVC = [self _topViewController:[[UIApplication sharedApplication].keyWindow rootViewController]];
    while (resultVC.presentedViewController) {
        resultVC = [self _topViewController:resultVC.presentedViewController];
    }
    return resultVC;
}

-(void)isShowLCPlayBar{
    
    NSArray<LCShowLCPlayBarVCListModel *> *showLCPlayBarArray = [NSArray lc_arrayWithPlist:@"showLCPlayBarVCList.plist" andClassName:@"LCShowLCPlayBarVCListModel"];
    
    for (NSInteger i = 0; i < showLCPlayBarArray.count; i++) {
        NSLog(@"[self topViewController] = %@", [self topViewController]);
        NSString *clzName = showLCPlayBarArray[i].vc;
        Class clz = NSClassFromString(clzName);//将字符串转化成class
        
        if ([[self topViewController] isKindOfClass:[clz class]]) {
            [LCFloatingWindow sharedInstance].hidden = NO;
            return;
        } else {
            [LCFloatingWindow sharedInstance].hidden = YES;
        }
    }
    
}


@end
